{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class MinStack(object):\n",
    "\n",
    "    def __init__(self):\n",
    "        \"\"\"\n",
    "        initialize your data structure here.\n",
    "        \"\"\"\n",
    "        self.stack = []\n",
    "        \n",
    "\n",
    "    def push(self, x):\n",
    "        \"\"\"\n",
    "        :type x: int\n",
    "        :rtype: None\n",
    "        \"\"\"\n",
    "        self.stack.append(x)\n",
    "\n",
    "\n",
    "    def pop(self):\n",
    "        \"\"\"\n",
    "        :rtype: None\n",
    "        \"\"\" \n",
    "        if self.stack:\n",
    "            self.stack = self.stack[:-1]\n",
    "\n",
    "\n",
    "    def top(self):\n",
    "        \"\"\"\n",
    "        :rtype: int\n",
    "        \"\"\"\n",
    "        if self.stack:\n",
    "            return self.stack[-1]\n",
    "\n",
    "        \n",
    "    def getMin(self):\n",
    "        \"\"\"\n",
    "        :rtype: int\n",
    "        \"\"\"\n",
    "        if self.stack:\n",
    "            min = self.stack[0]\n",
    "            for x in self.stack:\n",
    "                if x < min:\n",
    "                    min = x\n",
    "            return min\n",
    "        else:\n",
    "            return None\n",
    "\n",
    "\n",
    "# Your MinStack object will be instantiated and called as such:\n",
    "# obj = MinStack()\n",
    "# obj.push(x)\n",
    "# obj.pop()\n",
    "# param_3 = obj.top()\n",
    "# param_4 = obj.getMin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = [1,2,3]\n",
    "a[:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
